package com.gkj.blog.business.vo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gkj.blog.business.enums.SexEnum;
import com.gkj.blog.business.enums.UserStatusEnum;
import com.gkj.blog.business.enums.UserTypeEnum;
import com.gkj.blog.framework.object.BaseEntityVo;
import com.gkj.blog.persistence.po.SysUser;

import java.util.Date;

public class User extends BaseEntityVo {
    SysUser sysUser;

    public User(SysUser sysUser) {
        this.sysUser = sysUser;
        setAbstractDO(sysUser);
    }

    public User() {
        this.sysUser=new SysUser();
        setAbstractDO(sysUser);
    }

    public String getUsername() {
        return sysUser.getUsername();
    }

    public void setUsername(String username) {
        sysUser.setUsername(username);
    }

    public String getPassword() {
        return sysUser.getPassword();
    }

    public void setPassword(String password) {
        sysUser.setPassword(password);
    }

    public String getNickname() {
        return sysUser.getNickname();
    }

    public void setNickname(String nickname) {
        sysUser.setNickname(nickname);
    }

    public String getEmail() {
        return sysUser.getEmail();
    }

    public void setEmail(String email) {
        sysUser.setEmail(email);
    }

    public String getQq() {
        return sysUser.getQq();
    }

    public void setQq(String qq) {
        sysUser.setQq(qq);
    }

    public String getSex() {
        SexEnum sex = SexEnum.get(sysUser.getSex());
        return sex==null?null:sex.getSex();
    }

    public void setSex(String sex) {
        sysUser.setSex(SexEnum.getBySex(sex).getCode());
    }

    public String getAvatar() {
        return sysUser.getAvatar();
    }

    public void setAvatar(String avatar) {
        sysUser.setAvatar(avatar);
    }

    public UserTypeEnum getUserType() {
        return UserTypeEnum.getByType(sysUser.getUserType());
    }

    public void setUserType(String userType) {
        sysUser.setUserType(userType);
    }

    public String getOrigin() {
        return sysUser.getOrigin();
    }

    public void setOrigin(String origin) {
        sysUser.setOrigin(origin);
    }

    public String getRegIp() {
        return sysUser.getRegIp();
    }

    public void setRegIp(String regIp) {
        sysUser.setRegIp(regIp);
    }

    public String getLastLoginIp() {
        return sysUser.getLastLoginIp();
    }

    public void setLastLoginIp(String lastLoginIp) {
        sysUser.setLastLoginIp(lastLoginIp);
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    public Date getLastLoginTime() {
        return sysUser.getLastLoginTime();
    }

    public void setLastLoginTime(Date lastLoginTime) {
        sysUser.setLastLoginTime(lastLoginTime);
    }

    public Integer getLoginCount() {
        return sysUser.getLoginCount();
    }

    public void setLoginCount(Integer loginCount) {
        sysUser.setLoginCount(loginCount);
    }

    public String getRemark() {
        return sysUser.getRemark();
    }

    public void setRemark(String remark) {
        sysUser.setRemark(remark);
    }

    public UserStatusEnum getStatus() {
        return UserStatusEnum.get(sysUser.getStatus());
    }

    public void setStatus(Integer status) {
        sysUser.setStatus(status);
    }

}
